from GDHS import *


if __name__ == "__main__":
    function = "Step"
    vardim = 30
    size = 5
    U = float(100)
    L = float(-100)
    MAXGEN = 7000

    result = []

    for i in range(1):
        bound = np.tile([[L], [U]], vardim)
        GDHS = GDHSImprovedHarmonySearch(size, vardim, bound, MAXGEN,function)
        GDHS.solve()

    result.append(float(GDHS.best.fitness))

    print("---GDHS---")
    print(np.mean(result))
    print(np.std(result))
    print("------")

    y = GDHS.trace
    plt.rcParams['axes.unicode_minus'] = False
    text = "Dimension:" + str(vardim) + "  Function:" + function
    plt.title(text)
    plt.xlabel("Iterations")
    plt.ylabel("Function value")
    plt.plot(y, label='GDHS', linestyle=":")

    plt.legend()
    plt.show()